<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .divxx {
      width: 200px;
      height: 200px;
      background-color: red;
      line-height: 200px;
      font-size: 20px;
    }

  </style>
</head>

<body>
  <div class="divxx">
    <div>
      哈哈哈测试
    </div>
  </div>
  <input type="text" maxlength="11">
</body>
<script>
  const a = new Promise(function (resolve, reject) {
    let num = 2
    setTimeout(() => {
      num = num - Math.floor(Math.random() * 2)
      if (num === 1) {
        resolve(num)
      }
      reject(num)
    }, 2000)
  })


  // console.log('top');
  // a.then((res) => {
  //   console.log(res);
  // }, (res) => {
  //   console.log(res);
  // })
  // console.log('bottom');

  async function test() {
    console.log('async');
    const res = await a
    console.log(res);
  }
  console.log('top');
  test()
  console.log('bottom');
</script>

</html>
